
<template>
  <!-- 怪物卡模板 -->
  <div class="card" style="box-sizing: border-box">
    <div class="top">
      <div class="left head">{{ itemData.hp }}</div>
      <div :class="`ele head ${cardEle}`">{{ itemData.ele }}</div>
      <div class="name head">{{ itemData.name }}</div>
      <div class="right head">{{ itemData.exp }}</div>
    </div>
    <div class="pic">
      <img class="img" :src="imgurl" alt="QQ:869812188" />
    </div>
    <div class="tag">
      <div class="tagtypes">{{getTag(itemData.tag1,itemData.tag2,itemData.tag3)}}</div>
      <div :class="`spd ${cardEle}`">{{ itemData.spd }}</div>
      <div class="tagNo">{{ itemData.No }}</div>
    </div>
    <div class="remark">
      <div :class="`skill ${cardEle}`">
        <div class="skill-type">特性</div>
        <div class="skill-ability">{{ itemData.ability }}</div>
      </div>
      <div :class="`skill ${cardEle}`">
        <div class="skill-type">攻击</div>
        <div class="skill-ability">{{ itemData.spd }},{{ itemData.att }}</div>
      </div>
      <div :class="`skill ${cardEle}`">
        <div class="skill-type">辅助</div>
        <div class="skill-ability">{{ itemData.sup }}</div>
      </div>
    </div>
  </div>
</template>
<script>
import helper from '../service/helper.js';
export default {
  props: ["itemData"],
  data() {
    return {
      imgurl: "",
      cardEle: " ",
    };
  },
  watch: {
    itemData: function (newVal, oldVal) {
      this.imgurl = require("../assets/images/pic/" + newVal.img);
      console.log("watch", this.imgurl);
      if (newVal.ele == "金") {
        this.cardEle = "j";
      } else if (newVal.ele == "木") {
        this.cardEle = "m";
      } else if (newVal.ele == "水") {
        this.cardEle = "s";
      } else if (newVal.ele == "火") {
        this.cardEle = "h";
      } else if (newVal.ele == "土") {
        this.cardEle = "t";
      } else {
        this.cardEle = "w";
      }
    },
  },
  methods: {
    reset() {
      var that = this
      var mountCard = that.itemData;
      that.imgurl = require("../assets/images/pic/" + mountCard.img);
      if (mountCard.ele == "金") {
        that.cardEle = "j";
      } else if (mountCard.ele == "木") {
        that.cardEle = "m";
      } else if (mountCard.ele == "水") {
        that.cardEle = "s";
      } else if (mountCard.ele == "火") {
        that.cardEle = "h";
      } else if (mountCard.ele == "土") {
        that.cardEle = "t";
      } else {
        that.cardEle = "w";
      }
    },
     getTag(tag1,tag2,tag3) {
       return helper.getTags(tag1,tag2,tag3)
    },
  },
  mounted() {
    this.reset();
  },
};
</script>
<style lang="less" >
.card {
  background-color: rgb(170, 215, 235);
  padding: 2px;
  width: 200px;
  height: 300px;
  .top {
    display: flex;
    .head {
      height: 30px;
      background-color: rgb(170, 215, 235);
      line-height: 30px;
    }
    .name {
      width: 100px;
      font-weight: bolder;
    }
    .right {
      width: 40px;
      background-color: rgb(255, 255, 255);
      border-radius: 20px;
      border: rgb(0, 0, 0) solid 1px;
    }
    .left {
      width: 30px;
      border-radius: 30px;
      background-color: rgb(243, 20, 20);
      border: rgb(0, 0, 0) solid 1px;
    }
    .ele {
      width: 30px;
      height: 10%;
      border-radius: 30px;
      border: rgb(0, 0, 0) solid 1px;
    }
    .j {
      background-color: rgb(255, 247, 0);
    }
    .m {
      background-color: rgb(0, 255, 81);
    }
    .s {
      background-color: rgb(0, 106, 255);
    }
    .h {
      background-color: rgb(255, 0, 0);
    }
    .t {
      background-color: rgb(96, 94, 90);
      color: aliceblue;
    }
  }
  .pic {
    box-sizing: border-box;
    background-color: rgb(170, 215, 235);
    width: 100%;
    height: 40%;
    padding: 0 10px;
    margin: 10px 0;
    overflow: hidden;
    .img {
      //background-size:cover;
      //background-repeat:no-repeat;
      //object-fit: cover;//重要
      width: 100%;
      //height: 100%;
    }
  }
  .tag {
    display: flex;
    // justify-content: space-between;
    margin: 0 10px;
    padding: 0 10px;
    background-color: #fff;
    border-radius: 5px;
    line-height: 20px;
    font-size: 14px;
    .tagtypes {
      width: 70%;
      text-align: left;
    }
    .spd {
      width: 10%;
      width: 20px;
      height: 20px;
      text-align: center;
      line-height: 20px;
      font-weight: bolder;
      border-radius: 20px;
    }
    .tagNo {
      width: 20%;
      text-align: right;
    }
  }
  .j {
    background-color: rgb(255, 247, 0);
  }
  .m {
    background-color: rgb(0, 255, 81);
  }
  .s {
    background-color: rgb(0, 106, 255);
  }
  .h {
    background-color: rgb(255, 0, 0);
  }
  .t {
    background-color: rgb(96, 94, 90);
    color: aliceblue;
  }
  .remark {
    text-align: left;
    background-color: rgb(170, 215, 235);
    padding: 5px 10px;
    .skill {
      display: flex;
      height: 30px;
      .skill-type {
        min-width: 18%;
        font-weight: bolder;
        font-size: 14px;
        margin: 0 5px;
        width: 20%;
      }
      .skill-ability {
        word-break: break-all;
        font-size: 12px;
        width: 80%;
      }
    }
  }
}
</style>